package com.school.graduation.goods.presenter;

import android.content.Context;

import com.school.graduation.bean.GoodsBean;
import com.school.graduation.goods.model.FoundGoodDetailListener;
import com.school.graduation.goods.model.FoundGoodDetailModel;
import com.school.graduation.goods.model.ImplFoundGoodDetailModel;
import com.school.graduation.goods.view.ImplHotMarketDetails;
import com.school.graduation.model.Goods;
import com.school.graduation.util.ToastUtil;

import java.util.List;

public class FoundGoodDetailsPresenter implements FoundGoodDetailListener {

    private ImplHotMarketDetails hotMarketDetails;
    private ImplFoundGoodDetailModel hotMarketDetailModel;
    private Context context;

    public FoundGoodDetailsPresenter(Context context, ImplHotMarketDetails hotMarketDetails) {
        this.context = context;
        this.hotMarketDetails = hotMarketDetails;
        hotMarketDetailModel = new FoundGoodDetailModel();
    }

    @Override
    public void getGoodsesNew(List<GoodsBean> goods) {
        FoundGoodDetailAdapterNew adapter = new FoundGoodDetailAdapterNew(goods);
        hotMarketDetails.setDetailsAdapterNew(adapter);
    }

    @Override
    public void getError(String error) {
        hotMarketDetails.dismissProgressDialog();
        ToastUtil.makeShortToast(context,error);
    }

    public void getListsByInputNew(String input) {
        hotMarketDetailModel.getGoodsByInputNew(input,this);
    }

    public void getListBySortNew(String sort) {
        hotMarketDetailModel.getGoodsBySortNew(sort,this);
    }
}
